table.MOVE_RECORDS_TO Function

Syntax

Result as C = Table.Move_Records_To(C Tablename [,C Filter_Expression ])

Arguments

Tablename

The name of the table to receive the moved records.

Filter_Expression

Optional. Default = .T. (all records). A character filter expression that selects records in the source table to move. If Filter is not specified, the currently selected records in the source table are moved.

Description

Moves records to another table with similar structure

Discussion

The <TBL>.MOVE_RECORDS_TO() method moves records in the source table referenced by <TBL> to the target table specified by Table_Name. Data is moved from each field in the source table to the corresponding field with the same name in the target table. Result is a character string that indicates how many records were moved, and how many records could not be moved because they violated a field rule in the target table. For example, if Result is "230,3", it indicates that 230 records were moved and 3 records were not moved because of a field rule violation. The "violated" table in the Alpha Anywhere program folder shows which records were not moved. Table_Name can have more fields than the source table. However, at a minimum, it must have all of the fields in the source table, and they must be of the same type and size.

Example

This script moves current selection of records to "OLD_CUSTOMERS"

dim tbl as P
tbl_source = table.current()
query.filter = "state = 'ma'"
indx = tbl_source.query_create()
result = tbl_source.move_records_to("OLD_CUSTOMERS")
ui_msg_box("Result", word(result, 1) + " Records moved. " + word(result, 2) + " Records not moved (see Violated table).")

This script moves customers from "MA" to "OLD_CUSTOMERS"

dim tbl_source as P
tbl_source = table.current()
result = tbl_source.move_records_to("OLD_CUSTOMERS","state = 'ma'")
ui_msg_box("Result", word(result, 1) + " Records moved. " + word(result, 2) + " Records not moved (see Violated table).")

See Also